package com.google.coffeeshop.gui.desktop.seat;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JScrollPane;

import com.google.coffeeshop.business.LoadingBusiness;
import com.google.coffeeshop.entity.SeatDTO;
import com.google.coffeeshop.gui.desktop.ContentBasePanel;

public class SeatPanel extends ContentBasePanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private SeatTable seatTable;
	public SeatPanel(String constraints) {
		super(constraints);
		
		setLayout(new BorderLayout(0, 0));
		initializeGUI();
	}
	private void initializeGUI() {
		seatTable = new SeatTable();
		add(new JScrollPane(seatTable), BorderLayout.CENTER);
		putAllSeatsToTable(seatTable);
	}
	private void putAllSeatsToTable(SeatTable seatTable) {
		seatTable.addNewRows(LoadingBusiness.getAllSeats());
	}
	public void refreshGUI() {
		removeAll();
		initializeGUI();
		validate();
		repaint();
	}
	public long getProductSelectedId(){
		return seatTable.getSelectedProductId();
	}
	
	public List<SeatDTO> getSeatsSelected() {
		return seatTable.getSelectedSeats();
	}
}
